export DISTRIBUTED_CKPT_PATH="/home/zhangsenzhen/2023Q2/checkpoint_download/llama/ziya/multi_2/transformed_checkpoint/"

export RANK_TABLE_FILE=$1
DEVICE_RANGE=$2
DEVICE_RANGE_LEN=${#DEVICE_RANGE}
DEVICE_RANGE=${DEVICE_RANGE:1:DEVICE_RANGE_LEN-2}
PREFIX=${DEVICE_RANGE%%","*}
INDEX=${#PREFIX}
START_DEVICE=${DEVICE_RANGE:0:INDEX}
END_DEVICE=${DEVICE_RANGE:INDEX+1:DEVICE_RANGE_LEN-INDEX}

for((i=${START_DEVICE};i<${END_DEVICE};i++))
do
    export DEVICE_ID=$i
    export RANK_ID=$((i-START_DEVICE))
    echo "Start distribute running for rank $RANK_ID, device $DEVICE_ID"
    python chat.py &> mindformer_$RANK_ID.log &
done
